//这里写接口请求

import axios from "./axios";

/*export const getMenu=(param)=>{
  return axios.request({
    url:'http://123.207.32.32:8000/home/multidata',//接口地址
    method:'get',//接口类型
    data:param//传入的参数
  })
}*/
//写好接口调用时
//引用 import {getMenu方法名称} from '这个文件的相对地址'
//mounted() {
//     getMenu().then(res=>{
//       console.log(res)
//     })
//   }

export const getLogin = (params) => {//登录验证
  return axios.request({
    url: 'http://42.193.219.14:8080/login',//接口地址
    method: 'post',
    headers: {
      "Content-Type": "application/json"
    },
    data: params
  }).then(function (params) {
    return params.data
  })
}

export const addKnowledge = (params) => {//添加知识点
  return axios.request({
    url: 'http://42.193.219.14:8080/addKnowledgePoint',//接口地址
    method: 'post',
    headers: {"Authorization": "Bearer " + sessionStorage.getItem('token')},
    data: params
  }).then(function (response) {
    console.log(response);
  })
}

export const getCourse = () => {//获取学科
  return axios.request({
    url: 'http://42.193.219.14:8080/getSubjectByUid',//接口地址
    method: 'get',
    headers: {"Authorization": "Bearer " + sessionStorage.getItem('token')},
  }).then(function (params) {
    return params.data;
  })
}

export const getClass = () => {//获取班级
  return axios.request({
    url: 'http://42.193.219.14:8080/getClassByUid',//接口地址
    method: 'get',
    headers: {"Authorization": "Bearer " + sessionStorage.getItem('token')},
  }).then(function (params) {
    return params.data;
  })
}

export const getKnowledge = (params) => {//获取知识点
  return axios.request({
    url: 'http://42.193.219.14:8080/getKnowledgePointsBySid',//接口地址
    method: 'get',
    headers: {"Authorization": "Bearer " + sessionStorage.getItem('token')},
    params
  }).then(function (params) {
    return params.data;
  })
}

export const postTest = (params) => {//post试卷信息
  return axios.request({
    url: 'http://42.193.219.14:8080/intelligentGroupVolumes',
    method: 'post',
    headers: {
      'Content-Type': 'application/json',
      "Authorization": "Bearer " + sessionStorage.getItem('token')
    },
    data: params
  })
}

export const postPaper = (params) => {//post生成的试卷
  return axios.request({
    url: 'http://42.193.219.14:8080/paperMessage',
    method: 'post',
    headers: {
      'Content-Type': 'application/json',
      "Authorization": "Bearer " + sessionStorage.getItem('token')
    },
    data: params
  })
}

export const postPeoplePaper = (params) => {//post人工生成的试卷
  return axios.request({
    url: 'http://42.193.219.14:8080/paperPeopleMessage',
    method: 'post',
    headers: {
      'Content-Type': 'application/json',
      "Authorization": "Bearer " + sessionStorage.getItem('token')
    },
    data: params
  })
}

export const addClass = (params) => {//添加班级
  return axios.request({
    url: 'http://42.193.219.14:8080/addClass',//接口地址
    method: 'post',
    headers: {
      'Content-Type': 'application/json',
      "Authorization": "Bearer " + sessionStorage.getItem('token')
    },
    data: params
  }).then(function (res) {
    console.log(res);
    console.log("添加班级成功")
  })
}

export const getQuestionTittle = (params) => {//获取题目
  return axios.request({
    url: 'http://42.193.219.14:8080/getQuestionTittle',
    method: 'post',
    headers: {
      'Content-Type': 'application/json',
      "Authorization": "Bearer " + sessionStorage.getItem('token')
    },
    data: params
  })
}
